cmake_minimum_required(VERSION 3.20)

project(MyCObject)

set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/bin/")

set(LIBRARY_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib/")

link_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/")

aux_source_directory(. SRC)

foreach(TSRC ${SRC})
    get_filename_component(FNAME ${TSRC} NAME_WE)
    if(NOT FNAME STREQUAL "main")
        add_library(${FNAME} ${TSRC})
    endif()
endforeach()

add_executable("main.out" main.c)

foreach(TLIB ${SRC})

    get_filename_component(FNAME ${TLIB} NAME_WE)

    if(NOT FNAME STREQUAL "main")
        target_link_libraries("main.out" ${FNAME})
        # message(emm)
    endif()
    
endforeach(TLIB ${SRC})

